package cn.zptc.springbootdemo.domain;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.index.Indexed;
import org.springframework.stereotype.Component;

import javax.persistence.Id;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * @author ：zhaoweiwei
 * @date ：创建于 2025/2/27 13:47
 * @description：
 * @modified By：
 * @version: 1.0.0
 */
//@Component// 用于将Person类作为Bean注入到Spring容器中
//@ConfigurationProperties(prefix = "person") // 将配置文件中以person开头的属性注入到该类中
@RedisHash("persons")  // 指定操作实体类对象在Redis数据库中的存储空间
public class Person {

    @Id// 标识实体类主键
    private String id;
    // 标识对应属性在Redis数据库中生成二级索引,索引名就是属性名，可以方便地进行数据条件查询
    @Indexed
    private String firstname;
    @Indexed
    private String lastname;
    private Address address;
    private List<FamilyMember> familyMemberList;

    public Person() {    }

    public Person(String firstname, String lastname) {

        this.firstname = firstname;
        this.lastname = lastname;

    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getFirstname() {
        return firstname;
    }

    public void setFirstname(String firstname) {
        this.firstname = firstname;
    }

    public String getLastname() {
        return lastname;
    }

    public void setLastname(String lastname) {
        this.lastname = lastname;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public List<FamilyMember> getFamilyMemberList() {
        return familyMemberList;
    }

    public void setFamilyMemberList(List<FamilyMember> familyMemberList) {
        this.familyMemberList = familyMemberList;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id='" + id + '\'' +
                ", firstname='" + firstname + '\'' +
                ", lastname='" + lastname + '\'' +
                ", address=" + address +
                ", familyMemberList=" + familyMemberList +
                '}';
    }
}